import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_chapter_03_cls/demo/pages/UserBean.dart';

import '../pages/DemoPages.dart';
import '../pages/TowPages.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(title: const Text("Flutter App")),
        body: MyHomePage(),
      ),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return TextButton(
      child: const Text("通过实例跳转"),
      onPressed: () async {
        var result = await Navigator.of(context).push(
          //打开页面的风格 android 上下
          MaterialPageRoute(builder: (context){
            // return const DemoPage();
            return TwoPageRoute(
                text: "这里是text文本内容",
                userBean: UserBean("张三",18)
            );
          })
          //IOS 左右
          // CupertinoPageRoute(builder: (context){
          //   return const DemoPage();
          // })
        );

        print("result:$result");


      },
    );
  }
}
